package com.xbongbong.pro.enums.fund.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author zcp
 * @version v1.0
 * @since v1.0
 */
@Getter
public enum FundSetMenuEnum {
    /**
     * CRM模块的 应收规则设置
     */
    RECEIVABLE_RULES(XbbRefTypeEnum.CRM.getCode(), 1, "enum.fundSetMenu.name.receivable_rules"),

    RECONCILIATION_RULE(XbbRefTypeEnum.CRM.getCode(), 3, "enum.fundSetMenu.name.reconciliation_rule"),

    CREDIT_RULE(XbbRefTypeEnum.CRM.getCode(), 4, "enum.fundSetMenu.name.credit_rule"),

    WRITE_OFF_RULE(XbbRefTypeEnum.CRM.getCode(), 5, "enum.fundSetMenu.name.write_off_rule"),

    PAY_RULE(XbbRefTypeEnum.CRM.getCode(), 6, "enum.fundSetMenu.name.pay_rule"),
    ;

    /**
     * 资金设置菜单归属业务 1：crm 2：jxc
     *
     * @see XbbRefTypeEnum
     */
    private Integer refType;

    /**
     * 资金设置菜单type值
     */
    private Integer type;

    /**
     * 菜单名称
     */
    private String name;

    FundSetMenuEnum(Integer refType, Integer type, String name) {
        this.refType = refType;
        this.type = type;
        this.name = name;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public String getI18nName() {
        return name;
    }

    /**
     * 获取所属模块的菜单
     * @param refType
     * @return java.util.List<com.xbongbong.pro.enums.fund.enums.FundSetMenuEnum>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static List<FundSetMenuEnum> getEnumListByRefType(Integer refType) {
        List<FundSetMenuEnum> list = new ArrayList<>();
        for (FundSetMenuEnum cache : values()) {
            if (Objects.equals(cache.refType, refType)) {
                list.add(cache);
            }
        }
        return list;
    }

}
